package org.onion.pattern.event.outbox.data;


import lombok.Getter;

@Getter
public enum OutboxEventStatus {

    /**
     * 已创建
     */
    CREATED(0),

    /**
     * 已发送了
     */
    DELIVERED(4),

    /**
     * 已消费
     */
    CONSUME(8),

    /**
     * 中断
     */
    SUSPEND(16),
    ;

    private final int code;

    OutboxEventStatus(int i) {
        this.code = i;
    }

    public static OutboxEventStatus fromCode(int anInt) {
        switch (anInt) {
            case 0:
                return CREATED;
            case 4:
                return DELIVERED;
            case 8:
                return CONSUME;
            case 16:
                return SUSPEND;
        }
        throw new IllegalArgumentException("未知的参数 " + anInt);
    }

}
